﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Drawing;

namespace Graphene.Storing
{
    public class MarkerInImage : MyNamed, Mirker
    {
        public MarkerInImage(string myId, string myName, Color representingColor)
            : this(myId, myName, new PointReal2D(0, 0), false, System.Drawing.Color.Black, 0, 0, representingColor)
        {
        }

        public MarkerInImage(string myId, string myName, Color color, byte searchShadeTolerance, byte extendShadeTolerance, Color representingColor)
            : this(myId, myName, new PointReal2D(0, 0), false, color, searchShadeTolerance, extendShadeTolerance, representingColor)
        {
        }

        public MarkerInImage(string myId, string myName, PointReal2D position, bool exists, Color color, byte searchShadeTolerance, byte extendShadeTolerance, Color representingColor)
        {
            this.myId = myId;
            this.myName = myName;
            this.position = position;
            this.exists = exists;
            this.color = color;
            this.searchShadeTolerance = searchShadeTolerance;
            this.extendShadeTolerance = extendShadeTolerance;
            this.representingColor = representingColor;            
        }

        public Object Clone()
        {
            MarkerInImage m = new MarkerInImage(this.myId, this.myName, this.position, this.exists, this.color, this.searchShadeTolerance, this.extendShadeTolerance, this.representingColor);
            return m;
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            MarkerInImage m = obj as MarkerInImage;
            if ((System.Object)m == null)
            {
                return false;
            }

            return this.myId.Equals(m.MyId);
        }

        public override int GetHashCode()
        {
            return this.myId.GetHashCode();
        }

        public override string ToString()
        {
            return this.myId;
        }

        public string MyId
        {
            get { return this.myId; }
        }

        public string MyName
        {
            get { return this.myName; }
        }
        
        public PointReal2D Position
        {
            get { return position; }
            set { position = value; }
        }
        
        public bool Exists
        {
            get { return exists; }
            set { exists = value; }
        }
        
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }

        public Color RepresentingColor
        {
            get { return representingColor; }
            set { representingColor = value; }
        }      
        
        public byte SearchShadeTolerance
        {
            get { return searchShadeTolerance; }
            set { searchShadeTolerance = value; }
        }
        
        public byte ExtendShadeTolerance
        {
            get { return extendShadeTolerance; }
            set { extendShadeTolerance = value; }
        }

        private string myId;
        private string myName;

        private PointReal2D position;

        private bool exists;

        private Color color;

        /**
         * When we want to show the position of the marker we may draw colored x signs on a canvas.
         * This color should be a lighter and more saturated color than the original marker color.
         * It is for debugging or feedback purposes only.
         */
        private Color representingColor;

        private byte searchShadeTolerance;
        private byte extendShadeTolerance;  
    }
}
